/**
 * 
 */
package com.kbcss.web;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;


import com.kbcss.dao.DeptDao;
import com.kbcss.dao.UserDao;

import com.kbcss.dto.UserDetails;

/**
 * @author ibm123
 *
 */
@Controller
@RequestMapping(value="/adduser.spring")
public class CreateUserController {
	@Autowired
	private UserDao userdao;
	public void setUserDao(UserDao userdao){
        this.userdao=userdao;
    }
	@Autowired
	private DeptDao deptdao;
	public void setDeptDao(DeptDao deptdao){
		this.deptdao=deptdao;
	}
	
    
	@RequestMapping(method=RequestMethod.POST)
    public String storeUser(@ModelAttribute("user")UserDetails user,HttpServletRequest request){
        String message="User created successfully";
        try{
            userdao.createUser(user.getUserId(), user.getPassword(),user.getfName(),user.getlName(),user.getEmail(),user.getDob(),user.getGender(),user.getRegdNo(),user.getDepart(),user.getPhno());

        }
        catch(Exception ex){
            message="Error:"+ex.getMessage();
        }
        request.setAttribute("message", message);
        return "results";

    }



}
